<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/headeradmin.php");
?>

<section>
<hgroup>
<h1>Bewoner bewerken</h1>
</hgroup>

    
    <?php if(!isset($_POST['Submit'])) { 
    
    //Een 
    $query1 = "SELECT * FROM patient WHERE Id=".$_GET['id']."";
    $result1 = mysql_query($query1) or die (mysql_error());
    while ($row1 = mysql_fetch_array($result1))
    {
        $id = $row1['Id'];
        $firstname = $row1['FirstName'];
        $lastname = $row1['LastName'];
        $gender = $row1['Gender'];
        $dayofbirth = $row1['DayOfBirth'];
        $weight = $row1['Weight'];
        $length = $row1['Length'];
        $buildingid = $row1['BuildingId'];
        $maritalstatus = $row1['MaritalStatus'];
        $telnumber = $row1['TelNumber'];
        $email = $row1['Email'];
        $contactfirstname = $row1['ContactFirstName'];
        $contactlastname = $row1['ContactLastName'];
        $contactrelation = $row1['ContactRelation'];
        $contacttelnumber = $row1['ContactTelNumber'];
        $contactemail = $row1['ContactEmail'];
    }

    
    ?>
<form  name="patientform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table>
        <tr>
            <td style="text-align: right">Voornaam</td>
            <td><input required placeholder="Voornaam" name="voornaam" value="<?php echo $firstname; ?>" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Achternaam</td>
            <td><input required placeholder="Achternaam" value="<?php echo $lastname; ?>" name="achternaam" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Geslacht</td>
            <td>
                <div class="onoffswitch">
                    <input type="checkbox" name="geslacht" class="onoffswitch-checkbox" id="myonoffswitch" <?php if ($gender == "V") { echo "checked"; } ?>>
                    <label class="onoffswitch-label" for="myonoffswitch">
                    <div class="onoffswitch-inner">
                    <div class="onoffswitch-active"><div class="onoffswitch-switch">VROUW</div></div>
                    <div class="onoffswitch-inactive"><div class="onoffswitch-switch">MAN</div></div>
                    </div>
                    </label>
                </div> 
            </td>
        </tr>
        <tr>
            <td style="text-align: right">Geboortedatum: </td>
            <td>
                <?php
                    //get class into the page
                    require_once($_SERVER['DOCUMENT_ROOT'].'/ObstacleWebApp/classes/tc_calendar.php');

                    $day = date('d', strtotime($dayofbirth ));
                    $month = date('m', strtotime($dayofbirth ));
                    $year = date('Y', strtotime($dayofbirth ));

                    $myCalendar = new tc_calendar("date5", true, false);
                    $myCalendar->setIcon("../../images/iconCalendar.gif");
                    $myCalendar->setDate($day, $month, $year);
                    $myCalendar->setYearInterval(1920, 2050);
                    $myCalendar->dateAllow('1920-01-01', '2050-01-01');
                    $myCalendar->setDateFormat('j F Y');
                    $myCalendar->setAlignment('left', 'bottom');
                    $myCalendar->writeScript();
                ?>
            </td>
        </tr>
        <tr>
            <td style="text-align: right">Gewicht (in kg)</td>
            <td><input required placeholder="Gewicht in kg" value="<?php echo $weight; ?>" name="gewicht" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Lengte (in cm)</td>
            <td><input required placeholder="Lengte in cm" value="<?php echo $length; ?>" name="lengte" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Adres: </td>
            <td>
                <select name="adres">
                <option value="0">Kies een adres</option>
                <?php
                $query3="SELECT city.ZIP as ZIP, city.City as City, building.Street as Street, building.Number as Number, building.Id as Id, building.CityId as CityId FROM building, city WHERE building.CityId = city.Id order by city.ZIP";
                $result3 = mysql_query($query3) or die ("FOUT1: " . mysql_error());
                while ($rij3 = mysql_fetch_array($result3))
                {
                    if ($buildingid == $rij3['Id'])
                    {
                        echo "<option selected value=\"".$rij3['Id']."\">".$rij3['ZIP']." ".$rij3['City'].", ".$rij3['Street']." ".$rij3['Number']."</option>";
                    }
                    else
                    {
                        echo "<option value=\"".$rij3['Id']."\">".$rij3['ZIP']." ".$rij3['City'].", ".$rij3['Street']." ".$rij3['Number']."</option>";
                    }
                }
                ?>
            </td>
        </tr>
        <tr>
            <td style="text-align: right">Burgerlijke status </td>
            <td>
                <select name="burgstatus">
                <option value="0">Kies een burgerlijke status</option>
                <?php
                $query4="SELECT * FROM maritalstatus";
                $result4 = mysql_query($query4) or die ("FOUT1: " . mysql_error());
                while ($rij4 = mysql_fetch_array($result4)){
                    if ($maritalstatus == $rij4['Id'])
                    {
                        echo "<option selected value=\"".$rij4['Id']."\">".$rij4['Name']."</option>";
                    }
                    else
                    {
                        echo "<option value=\"".$rij4['Id']."\">".$rij4['Name']."</option>";
                    }
                }
                ?>
                </select>
            </td>
            </tr>
        <tr>
            <td style="text-align: right">Telefoonnummer</td>
            <td><input required placeholder="Telefoonnummer" value="<?php echo $telnumber; ?>" name="telnummer" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Email-adres</td>
            <td><input required placeholder="Email-adres" value="<?php echo $email; ?>" name="email" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Voornaam contactpersoon</td>
            <td><input required placeholder="Voornaam contactpersoon" value="<?php echo $contactfirstname; ?>" name="contactvoornaam" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Achternaam contactpersoon</td>
            <td><input required placeholder="Achternaam contactpersoon" value="<?php echo $contactlastname; ?>" name="contactachternaam" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Relatie contactpersoon t.o.v. bewoner</td>
            <td><input required placeholder="Relatie" value="<?php echo $contactrelation; ?>" name="relatie" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Telefoonnummer contactpersoon</td>
            <td><input required placeholder="Telefoonnummer" value="<?php echo $contacttelnumber; ?>" name="contacttelnummer" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Email-adres contactpersoon</td>
            <td><input required placeholder="Email-adres" value="<?php echo $contactemail; ?>" name="contactemail" type="text"></td>
        </tr>
        <tr>
            <td style="text-align: right">Toewijzen aan zorgprofessional</td>
            <td>
                <select name="gebruiker">
                <option value="0">Toewijzen aan zorgprofessional</option>
                <?php
                
                $query12 = "SELECT * FROM patientuser WHERE PatientId = ".$id."";
                $result12 = mysql_query($query12) or die ("FOUT1: " . mysql_error());
                while ($rij12 = mysql_fetch_array($result12)){
                    $userid = $rij12['UserId'];
                }
                
                $query13="SELECT * FROM user";
                $result13 = mysql_query($query13) or die ("FOUT1: " . mysql_error());
                while ($rij13 = mysql_fetch_array($result13)){
                    if ($rij13['Id'] == $userid)
                    {
                        echo "<option selected value=\"".$rij13['Id']."\">".$rij13['LastName']." ".$rij13['FirstName']."</option>";
                    }
                    else
                    {
                        echo "<option value=\"".$rij13['Id']."\">".$rij13['LastName']." ".$rij13['FirstName']."</option>";
                    }
                }
                ?>
                </select>
            </td>
        </tr>
        <tr>
            <td style="text-align: right">Loop-hulpmiddelen</td>
            <td>
        <?php
        
            $query6 = "SELECT * FROM patientusedaid WHERE PatientId=".$id."";
            $result6 = mysql_query($query6) or die (mysql_error());
            while($row6 = mysql_fetch_array($result6))
            {
                $query7 = "SELECT * FROM usedaid WHERE Id=".$row6['UsedAidId']." AND Id>0";
                $result7 = mysql_query($query7) or die (mysql_error());
                while($row7 = mysql_fetch_array($result7))
                {
                    echo $row7['Name'];
                    echo "<br>";
                }
            }
        ?>
                <?php if (isset($_GET['start'])) {?>
                        Klik <a href="patientloophulpmiddelen.php?id=<?php echo $_GET['id'] ?>&start=<?php echo $_GET['start'] ?>">hier</a> om de loophulpmiddelen voor deze patiënt te beheren.
                    <?php } else{ ?>
                        Klik <a href="patientloophulpmiddelen.php?id=<?php echo $_GET['id'] ?>">hier</a> om de loophulpmiddelen voor deze patiënt te beheren.
                    <?php } ?>
                
            </td>
        </tr>
        
        
        <?php
        
            $query8 = "SELECT * FROM movementrestriction WHERE Activated='T'";
            $result8 = mysql_query($query8) or die (mysql_error());
            while ($row8 = mysql_fetch_array($result8))
            {
                $query9 = "SELECT * FROM patientmovementrestriction WHERE MovementRestrictionId=".$row8['Id']." AND PatientId=".$id."";
                $result9 = mysql_query($query9) or die (mysql_error());
                while ($row9 = mysql_fetch_array($result9))
                {
                    if ($row9['Value'] == 2)
                    {
                        echo "<tr><td style=\"text-align: right\">".$row8['MRKey']."</td><td>";
                                
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star required\" value=\"1\" title=\"1\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\" checked/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                        
                        echo "<select name=\"hulpmiddel".$row8['Id']."\">";
                        
                        $query10 = "SELECT * FROM patientusedaid WHERE PatientId=".$id."";
                        $result10 = mysql_query($query10) or die (mysql_error());
                        while ($row10 = mysql_fetch_array($result10))
                        {
                            $query11 = "SELECT * FROM usedaid WHERE Id=".$row10['UsedAidId']."";
                            $result11 = mysql_query($query11) or die (mysql_error());
                            while ($row11 = mysql_fetch_array($result11))
                            {
                                if ($row9['PatientUsedAidId'] == $row10['Id'])
                                {
                                    echo "<option selected value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                                else
                                {
                                    echo "<option value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                            }
                        }
                        
                        echo "</select></td>";
                    }
                    elseif ($row9['Value'] == 3)
                    {
                        echo "<tr><td style=\"text-align: right\">".$row8['MRKey']."</td><td>";
                                
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star required\" value=\"1\" title=\"1\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\" checked/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                        
                        echo "<select name=\"hulpmiddel".$row8['Id']."\">";
                        
                        $query10 = "SELECT * FROM patientusedaid WHERE PatientId=".$id."";
                        $result10 = mysql_query($query10) or die (mysql_error());
                        while ($row10 = mysql_fetch_array($result10))
                        {
                            $query11 = "SELECT * FROM usedaid WHERE Id=".$row10['UsedAidId']."";
                            $result11 = mysql_query($query11) or die (mysql_error());
                            while ($row11 = mysql_fetch_array($result11))
                            {
                                if ($row9['PatientUsedAidId'] == $row10['Id'])
                                {
                                    echo "<option selected value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                                else
                                {
                                    echo "<option value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                            }
                        }
                        
                        echo "</select></td>";
                    }
                    elseif ($row9['Value'] == 4)
                    {
                        echo "<tr><td style=\"text-align: right\">".$row8['MRKey']."</td><td>";
                                
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star required\" value=\"1\" title=\"1\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\" checked/>";
                        
                        echo "<select name=\"hulpmiddel".$row8['Id']."\">";
                        
                        $query10 = "SELECT * FROM patientusedaid WHERE PatientId=".$id."";
                        $result10 = mysql_query($query10) or die (mysql_error());
                        while ($row10 = mysql_fetch_array($result10))
                        {
                            $query11 = "SELECT * FROM usedaid WHERE Id=".$row10['UsedAidId']."";
                            $result11 = mysql_query($query11) or die (mysql_error());
                            while ($row11 = mysql_fetch_array($result11))
                            {
                                if ($row9['PatientUsedAidId'] == $row10['Id'])
                                {
                                    echo "<option selected value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                                else
                                {
                                    echo "<option value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                            }
                        }
                        
                        echo "</select></td>";
                    }
                    else
                    {
                        echo "<tr><td style=\"text-align: right\">".$row8['MRKey']."</td><td>";
                                
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star required\" value=\"1\" title=\"1\" checked/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                        echo "<input name=\"mv".$row8['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                        
                        echo "<select name=\"hulpmiddel".$row8['Id']."\">";
                        
                        $query10 = "SELECT * FROM patientusedaid WHERE PatientId=".$id."";
                        $result10 = mysql_query($query10) or die (mysql_error());
                        while ($row10 = mysql_fetch_array($result10))
                        {
                            $query11 = "SELECT * FROM usedaid WHERE Id=".$row10['UsedAidId']."";
                            $result11 = mysql_query($query11) or die (mysql_error());
                            while ($row11 = mysql_fetch_array($result11))
                            {
                                if ($row9['PatientUsedAidId'] == $row10['Id'])
                                {
                                    echo "<option selected value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                                else
                                {
                                    echo "<option value=\"".$row10['Id']."\">".$row11['Name']."</option>";
                                }
                            }
                        }
                        
                        echo "</select></td>";
                    }
                    
                }
            }
        
        ?>
        
        <?php
        

            $query5 = "SELECT * FROM patientspec WHERE Activated='T'";
            $result5 = mysql_query($query5) or die (mysql_error());
            while($row5 = mysql_fetch_array($result5))
            {
                echo "<tr><td style=\"text-align: right\">".$row5['PatientKey']."</td>";
                
                $query8 = "SELECT * FROM patientdetail WHERE PatientId=".$id." AND PatientSpecId = ".$row5['Id']."";
                $result8 = mysql_query($query8) or die (mysql_error());
                $num_rows8 = mysql_num_rows($result8);
                
                if ($num_rows8 == 0)
                {
                    echo "<td><input placeholder=\"".$row5['Comment']."\" name=\"".$row5['Id']."\" type=\"text\"></td>";
                }
                else
                {
                    while($row8 = mysql_fetch_array($result8))
                    {
                        echo "<td><input placeholder=\"".$row5['Comment']."\" value=\"".$row8['Value']."\" name=\"".$row5['Id']."\" type=\"text\"></td>";
                    }
                }
            }

        ?>
        
 	<tr>
            <td><input type="submit" name="Submit" value="Aanpassen">
            <input type="hidden" name="patientid" value="<?php echo $id ?>" />
            <input type="hidden" name="search" value="<?php if (isset($_GET['search'])){ echo $_GET['search']; } else { echo "0"; }  ?>" />
            <input type="hidden" name="start" value="<?php if (isset($_GET['start'])){ echo $_GET['start']; } else { echo 0; }  ?>" /></td>
            <td><input type="button" value="Terug" onclick="javascript:history.back();" /></td>
        </tr>
</table>
</form>
    <?php 
} 
else {
    
        $error = array();
	if(!check_email($_POST['email'])) {
		$error[] = 'Er is geen geldig e-mailadres ingevuld.';
	}
        
	if($_POST['voornaam'] == "") {
		$error[] = 'Er is geen voornaam ingevuld.';
	}
        
        if (!preg_match('`^[a-zA-Z]+$`',$_POST['voornaam']))
        {
            $error[] = 'Er mogen geen cijfers in de voornaam staan.';
        }
        
        if($_POST['achternaam'] == "") {
		$error[] = 'Er is geen achternaam ingevuld.';
	}
        
        if (!preg_match('`^[a-zA-Z]+$`',$_POST['achternaam']))
        {
            $error[] = 'Er mogen geen cijfers in de achternaam staan.';
        }
    
        if(!isset($_REQUEST["date5"])) {
		$error[] = 'Er is geen geboortedatum ingevuld.';
	}
        else
        {
            $theDate = date('Y-m-d', strtotime($_REQUEST["date5"]));
        }
        
        if(isset($_POST['geslacht'])) {
		$geslacht = "V";
	}
        else
        {
            $geslacht = "M";
        }
        
        if ($_POST['gewicht'] == "")
        {
            $error[] = 'Het gewicht is niet ingevuld.';
        }
        
        if (!is_numeric($_POST['gewicht']))
        {
            $error[] = 'Het gewicht kunnen enkel cijfers zijn.';
        }
        
        if ($_POST['lengte'] == "")
        {
            $error[] = 'De lengte is niet ingevuld.';
        }
        
        if (!is_numeric($_POST['lengte']))
        {
            $error[] = 'De lengte kunnen enkel cijfers zijn.';
        }
        
        if ($_POST['burgstatus'] == 0)
        {
            $error[] = 'Er is geen burgerlijke status geselecteerd.';
        }
        
        if ($_POST['gebruiker'] == 0)
        {
            $error[] = 'Er is geen zorgprofessional toegewezen.';
        }
        
        if ($_POST['telnummer'] == "")
        {
            $error[] = 'Het telefoonnummer is niet ingevuld.';
        }
        
        
        if(!check_email($_POST['contactemail'])) {
		$error[] = 'Er is geen geldig e-mailadres van de contactpersoon ingevuld.';
	}
        
	if($_POST['contactvoornaam'] == "") {
		$error[] = 'Er is geen voornaam van de contactpersoon ingevuld.';
	}
        
        if (!preg_match('`^[a-zA-Z]+$`',$_POST['contactvoornaam']))
        {
            $error[] = 'Er mogen geen cijfers in de voornaam van de contactpersoon staan.';
        }
        
        if($_POST['contactachternaam'] == "") {
		$error[] = 'Er is geen achternaam van de contactpersoon ingevuld ingevuld.';
	}
        
        if (!preg_match('`^[a-zA-Z]+$`',$_POST['contactachternaam']))
        {
            $error[] = 'Er mogen geen cijfers in de achternaam van de contactpersoon staan.';
        }
        
        if($_POST['relatie'] == "") {
		$error[] = 'Er is geen relatie van de contactpersoon t.o.v. de bewoner ingevuld.';
	}
        
        if($_POST['contacttelnummer'] == "") {
		$error[] = 'Er is geen telefoonnummer van de contactpersoon ingevuld ingevuld.';
	}
        
        $query9="SELECT * FROM patient WHERE BuildingId=".$_POST['adres']."";
        $result9 = mysql_query($query9) or die (mysql_error());
        $num_rows9 = mysql_num_rows($result9);
        if ($num_rows9 >= 1)
        {
            while ($row9 = mysql_fetch_array($result9))
            {
                if ($row9['Id'] != $_POST['patientid'])
                {
                    $error[] = 'Er woont al iemand op dit adres. (Klik <a href="gebouwdetail.php?id='.$_POST['adres'].'" >hier</a> om te kijken wie er woont)';
                }
            }   
        }
        
        $errors = sizeof($error); // aantal errors tellen
        if($errors != 0) { // Er is minstens 1 error
          echo "<p><span style=\"color:red\">De bewoner kon niet worden gewijzigd omwille van de volgende reden(en):</span></p><ul>";
            for($i = 0; $i < $errors; $i++) {
                echo "<span style=\"color:red\"><li>".$error[$i]."</li></span>";
            }
            echo "</ul>";
        } 
        else 
        {
            mysql_query("UPDATE patient SET FirstName='".$_POST['voornaam']."', LastName='".$_POST['achternaam']."', Gender='".$geslacht."', DayOfBirth='".$theDate."', Weight='".$_POST['gewicht']."', Length='".$_POST['lengte']."', BuildingId='".$_POST['adres']."', MaritalStatus='".$_POST['burgstatus']."', TelNumber='".$_POST['telnummer']."', Email='".$_POST['email']."', ContactFirstName='".$_POST['contactvoornaam']."', ContactLastName='".$_POST['contactachternaam']."', ContactRelation='".$_POST['relatie']."', ContactTelNumber='".$_POST['contacttelnummer']."', ContactEmail='".$_POST['contactemail']."'  WHERE Id=".$_POST['patientid']."");

            mysql_query("UPDATE patientuser SET UserId='".$_POST['gebruiker']."' WHERE PatientId = '".$_POST['patientid']."'");
            
            $deleten = array();
            $query6 = "SELECT * FROM patientspec WHERE Activated='T'";
            $result6 = mysql_query($query6) or die (mysql_error());
            while($row6 = mysql_fetch_array($result6))
            {
                $query7 = "SELECT * FROM patientdetail WHERE PatientId=".$_POST['patientid']." AND PatientSpecId = ".$row6['Id']."";
                $result7 = mysql_query($query7) or die (mysql_error());
                $num_rows7 = mysql_num_rows($result7);

                if ($num_rows7 == 0)
                {
                    if (isset($_POST[$row6['Id']]) && $_POST[$row6['Id']] != "")
                    {
                        mysql_query("INSERT INTO patientdetail (PatientId, PatientSpecId, Value) VALUES ('".$_POST['patientid']."', '".$row6['Id']."', '".$_POST[$row6['Id']]."')");
                    }
                }
                else
                {
                    while($row7 = mysql_fetch_array($result7))
                    {
                        if ($_POST[$row6['Id']] != "")
                        {
                            mysql_query("UPDATE patientdetail SET Value='".$_POST[$row6['Id']]."' WHERE Id=".$row7['Id']."");
                        }
                        else
                        {
                            $deleten[] = $row7['Id'];
                        }
                    }
                }
            }

            $query12 = "SELECT * FROM usedaid where Activated='T' AND Id > 0";
            $result12 = mysql_query($query12) or die (mysql_error());
            while ($row12 = mysql_fetch_array($result12))
            {
                $value = $_POST['mv'.$row12['Id']];
                $patientusedaidid = $_POST['hulpmiddel'.$row12['Id']];
                mysql_query("UPDATE patientmovementrestriction SET PatientUsedAidId=".$patientusedaidid.", Value=".$value."  WHERE MovementRestrictionId=".$row12['Id']." AND PatientId=".$_POST['patientid']."");
            }
            
            $number_deletes = sizeof($deleten);
            if($number_deletes != 0) { // Er moet minstens 1 value verwijderd worden
                for($i = 0; $i < $number_deletes; $i++) {
                    mysql_query("DELETE FROM patientdetail WHERE Id=".$deleten[$i]."");
                }
            }
            echo "De bewoner is aangepast.<br>";
            if ($_POST['search'] == "0")
            {
                echo "Klik <a href=\"patient.php?start=".$_POST['start']."\">hier</a> om terug te gaan naar het overzicht.";
            }
            else
            {
                echo "Klik <a href=\"patient.php\">hier</a> om terug te gaan naar het overzicht.";
            }
            
            
            
            
        }
    
    
    
    
    

}
?>

</section>

<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/footer.php");
?>